<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>state</title>
</head>
<body>
    <div id="test"></div>
    <script src="../../17之前版本/react.development.js"></script>
    <script src="../../17之前版本/react-dom.development.js"></script>
    <script src="../../17之前版本/prop-types.js"></script>
    <script src="../../17之前版本/babel.min.js"></script>

    <script type="text/babel">
        class Demo extends React.Component{
            constructor(props){
                super(props)
                this.state = {isHot:true}
                this.change = this.change.bind(this)
            }
            change(){
                console.log('标题被点击了');
                this.setState({isHot:!this.state.isHot})
            }
            render(){
                return <h1 onClick={this.change}>今天天气很{this.state.isHot ? '炎热':'凉爽'}</h1>
            }
        }
        let isHot = true
        ReactDOM.render(<Demo/>,document.getElementById('test'))
    </script>
</body>
</html>